package ro.ncit.tutorial01;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class MySimpleArrayAdapter extends ArrayAdapter<String> {

	private Context context;
	private String[] valori;
	
	
	public MySimpleArrayAdapter(Context context, int textViewResourceId, String[] valori) {
		super(context, textViewResourceId, valori);

		this.context = context;
		this.valori = valori;
		
		
	}

	@Override
	  public View getView(int position, View convertView, ViewGroup parent) {
		
		/**
		 * Incarca in memorie XML-ul.
		 */
	    LayoutInflater inflater = (LayoutInflater) context
	        .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	    
	    /**
	     * Incarca in memorie XML-ul list_item.xml
	     */
	    View rowView = inflater.inflate(R.layout.list_item, parent, false);
	    
	    /**
	     * Gaseste TextView-ul nostru, care are ID-ul "label".
	     */
	    TextView textView = (TextView) rowView.findViewById(R.id.label);
	    
	    /**
	     * Seteaza textul.
	     */
	    textView.setText(this.valori[position]);
	    
	    /**
	     * TODO: Creaza un ImageView in XML si gaseste-l aici.
	     * Apoi aplica-i o poza.
	     * 
	     *  HINT:
	     *  
	     *  	ImageView image = (ImageView) rowView.findResourceById(R.id.id-ul image view-ului tau);
	     *  	image.setImageResource(R.drawable.o poza care ai pus-o intr-un folder de drawable din stanga);
	     *  	
	     *  
	     *  
	     */
	    
	    
	    
	    
	    return rowView;
	  }
	
	
	
	
}
